/* Copyright (c) 2012-2013, Xiaomi corporation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
#include <linux/mfd/pm8xxx/pm8921-bms.h>

static struct single_row_lut fcc_temp = {
	.x		= {-20, -10, 0, 5, 10, 15, 20, 25, 30, 40, 50, 60},
	.y		= {2071, 2068, 2070, 2079, 2102, 2076, 2100, 2095, 2091, 2068, 2076, 2062},
	.cols	= 12
};

static struct single_row_lut fcc_sf = {
	.x		= {0},
	.y		= {100},
	.cols		= 1
};

static struct sf_lut rbatt_sf = {
	.rows		= 29,
	.cols		= 12,
	.row_entries	= {-20, -10, 0, 5, 10, 15, 20, 25, 30, 40, 50, 60},
	.percent	= {100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
	.sf		= {
				{959, 403, 218, 173, 142, 123, 107, 100, 94, 88, 84, 83},
				{962, 405, 219, 172, 142, 123, 107, 100, 94, 88, 84, 83},
				{1017, 419, 223, 178, 147, 125, 111, 101, 94, 90, 84, 83},
				{1084, 451, 232, 185, 153, 129, 113, 103, 97, 90, 86, 84},
				{1160, 492, 252, 198, 165, 135, 120, 107, 100, 92, 86, 84},
				{1166, 548, 276, 215, 179, 143, 127, 115, 104, 94, 88, 86},
				{961, 531, 292, 225, 190, 148, 132, 117, 107, 98, 90, 88},
				{922, 465, 313, 243, 209, 169, 148, 128, 118, 103, 95, 92},
				{915, 411, 288, 221, 192, 165, 148, 132, 120, 105, 97, 94},
				{911, 389, 219, 174, 147, 130, 120, 111, 103, 95, 89, 86},
				{919, 383, 213, 167, 140, 123, 109, 101, 96, 90, 86, 85},
				{944, 384, 213, 167, 140, 123, 110, 101, 96, 92, 86, 86},
				{996, 392, 215, 168, 143, 124, 111, 103, 97, 92, 89, 88},
				{1073, 400, 217, 169, 146, 125, 113, 105, 100, 93, 90, 88},
				{1182, 416, 220, 174, 146, 126, 113, 103, 98, 92, 88, 88},
				{1355, 441, 223, 174, 147, 125, 113, 101, 95, 90, 86, 85},
				{1617, 472, 225, 174, 146, 123, 108, 100, 94, 90, 86, 85},
				{1982, 521, 229, 173, 142, 122, 107, 99, 94, 88, 85, 84},
				{2552, 600, 235, 172, 140, 121, 107, 100, 95, 90, 86, 86},
				{2713, 635, 241, 176, 142, 123, 109, 101, 96, 90, 87, 86},
				{2892, 684, 248, 181, 146, 126, 112, 103, 98, 92, 89, 88},
				{3090, 742, 261, 192, 154, 128, 116, 105, 99, 94, 92, 92},
				{3309, 819, 282, 201, 162, 134, 119, 109, 102, 97, 94, 94},
				{3543, 900, 305, 215, 173, 137, 121, 109, 103, 95, 91, 89},
				{3808, 946, 313, 215, 165, 132, 117, 106, 98, 93, 89, 88},
				{4121, 994, 312, 210, 164, 134, 119, 107, 100, 96, 91, 91},
				{4498, 1100, 340, 225, 173, 142, 125, 114, 107, 103, 96, 96},
				{5032, 1276, 394, 258, 201, 165, 152, 138, 132, 115, 108, 110},
				{5032, 1276, 2098, 258, 2562, 2638, 366, 819, 988, 1097, 419, 396}
	}
};

static struct pc_temp_ocv_lut pc_temp_ocv = {
	.rows		= 29,
	.cols		= 12,
	.temp		= {-20, -10, 0, 5, 10, 15, 20, 25, 30, 40, 50, 60},
	.percent	= {100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
	.ocv		= {
				{4335, 4334, 4333, 4332, 4331, 4331, 4329, 4328, 4327, 4324, 4320, 4317},
				{4245, 4260, 4266, 4266, 4264, 4267, 4265, 4265, 4264, 4264, 4261, 4258},
				{4185, 4205, 4211, 4211, 4209, 4212, 4209, 4209, 4209, 4209, 4206, 4204},
				{4131, 4154, 4160, 4159, 4156, 4159, 4156, 4156, 4155, 4156, 4152, 4151},
				{4080, 4105, 4110, 4110, 4107, 4109, 4106, 4105, 4104, 4105, 4101, 4100},
				{4015, 4058, 4066, 4063, 4060, 4062, 4059, 4058, 4056, 4056, 4053, 4052},
				{3943, 3985, 3999, 4000, 3997, 4005, 4002, 4003, 4005, 4010, 4008, 4008},
				{3903, 3930, 3951, 3953, 3955, 3963, 3962, 3965, 3967, 3971, 3968, 3967},
				{3870, 3892, 3911, 3913, 3915, 3922, 3921, 3923, 3925, 3925, 3924, 3924},
				{3841, 3861, 3870, 3871, 3870, 3874, 3873, 3875, 3875, 3877, 3875, 3875},
				{3817, 3835, 3842, 3842, 3841, 3845, 3842, 3843, 3844, 3846, 3844, 3845},
				{3799, 3814, 3820, 3820, 3819, 3822, 3820, 3820, 3821, 3823, 3822, 3822},
				{3787, 3796, 3803, 3802, 3801, 3804, 3802, 3802, 3802, 3804, 3803, 3802},
				{3776, 3784, 3789, 3788, 3787, 3789, 3787, 3787, 3787, 3788, 3787, 3786},
				{3763, 3774, 3778, 3777, 3776, 3777, 3775, 3774, 3773, 3771, 3767, 3764},
				{3746, 3762, 3769, 3767, 3767, 3766, 3764, 3762, 3759, 3752, 3746, 3740},
				{3724, 3740, 3750, 3750, 3750, 3749, 3746, 3744, 3740, 3733, 3726, 3718},
				{3705, 3712, 3718, 3715, 3714, 3713, 3709, 3707, 3704, 3696, 3692, 3687},
				{3685, 3694, 3697, 3696, 3695, 3693, 3691, 3689, 3686, 3681, 3675, 3669},
				{3680, 3692, 3695, 3695, 3694, 3692, 3690, 3688, 3685, 3680, 3674, 3668},
				{3674, 3689, 3693, 3693, 3692, 3691, 3689, 3687, 3684, 3679, 3673, 3667},
				{3665, 3685, 3691, 3692, 3691, 3689, 3687, 3685, 3683, 3677, 3671, 3665},
				{3652, 3679, 3688, 3689, 3688, 3687, 3684, 3682, 3679, 3673, 3667, 3661},
				{3634, 3667, 3680, 3681, 3681, 3680, 3674, 3673, 3669, 3661, 3654, 3644},
				{3607, 3640, 3658, 3659, 3656, 3654, 3642, 3642, 3638, 3625, 3619, 3604},
				{3565, 3593, 3611, 3610, 3606, 3604, 3588, 3590, 3585, 3571, 3565, 3550},
				{3502, 3522, 3543, 3542, 3536, 3536, 3514, 3518, 3512, 3499, 3494, 3477},
				{3398, 3414, 3444, 3443, 3437, 3439, 3408, 3414, 3407, 3392, 3391, 3371},
				{3200, 3200, 3200, 3200, 3200, 3200, 3200, 3200, 3200, 3200, 3200, 3200}
	}
};

struct pm8921_bms_battery_data samsung_2000_data = {
	.fcc			= 2000,
	.fcc_temp_lut		= &fcc_temp,
	.fcc_sf_lut		= &fcc_sf,
	.pc_temp_ocv_lut	= &pc_temp_ocv,
	.rbatt_sf_lut		= &rbatt_sf,
	.default_rbatt_mohm	= 152
};
